package com.qf.controller;

import com.qf.pojo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/user")
@Api(tags = "用户模块")
public class UserController{

    @GetMapping
    @ApiOperation("获取所有用户")
    public List<User> getAll(){
        List<User> users = new ArrayList<>();
        User user = new User();
        user.setName("zs");
        user.setAge(18);
        User user1 = new User();
        user1.setName("ls");
        user1.setAge(28);
        users.add(user);
        users.add(user1);

        return users;
    }


    @GetMapping("/{name}")
    @ApiOperation("根据用户名获取指定用户")
    @ApiImplicitParam(name = "name",value = "用户名参数")
    public User getOne(@PathVariable String name){
        User user = new User();
        user.setName(name);
        user.setAge(18);

        return user;
    }
}
